/**
 * @param {number[]} nums
 * @return {string[]}
 */
var summaryRanges = function (nums) {
    const len = nums.length;
    let i = 0;
    const res = [];
    while (i < len) {
        const low = i;
        i++;
        while (i < len && nums[i] - nums[i - 1] === 1) {
            i++;
        }
        const high = i - 1;
        let str = '' + nums[low];
        if (low < high) {
            str += '->' + nums[high];
        }
        res.push(str);
    }
    return res;
};